package com.sq.universe.system.service.impl;

import com.sq.universe.base.service.impl.BaseServiceImpl;
import com.sq.universe.system.dao.RoleMenuDao;
import com.sq.universe.system.entity.RoleMenuEntity;
import com.sq.universe.system.entity.UserEntity;
import com.sq.universe.system.service.RoleMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author 孙乾 2020-07-08 23:32:27
*/
@Service
public class RoleMenuServiceImpl extends BaseServiceImpl<RoleMenuEntity, RoleMenuDao> implements RoleMenuService {

    @Autowired
    private RoleMenuDao systemRoleMenuDao;

    public void insertBatch(List<String> roleMenuEntityList, String roleCode, UserEntity userEntity){
        RoleMenuEntity roleMenuEntity = new RoleMenuEntity();
        roleMenuEntity.setRmRoleCode(roleCode);
        systemRoleMenuDao.logicalDelete(roleMenuEntity);
        for (String menuCode : roleMenuEntityList){
            RoleMenuEntity _roleMenuEntity = new RoleMenuEntity();
            _roleMenuEntity.setRmMenuCode(menuCode);
            _roleMenuEntity.setRmRoleCode(roleCode);
            _roleMenuEntity.setRmCreateTime(new Date());
            _roleMenuEntity.setRmCreateUser(userEntity.getUserId());
            systemRoleMenuDao.insert(_roleMenuEntity);
        }
    }

}
